import create from "zustand";
import produce from 'immer'

interface ZustandState {
	count: number,
	lush: any,
	addNumber: () => void,
	subNumber: any,
	resetNum: () => void,
	clearProperty: () => void,
}

const useStore = create<ZustandState>((set, get)  => ({
	count: 0,
	lush: { forest: { contains: { a: "bear" } } },
	addNumber: ()=> (
		set(state => ({count: get().count + 1}))
	),
	subNumber: ()=> set({count: get().count - 1}),
	resetNum: ()=> set({count: 0}),
	clearProperty: ()=> set(produce(state=> {
		state.lush.forest.contains = null
	}))
}))

export default useStore;